<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:78:"/Users/yandian/work/matian/application/admin/view/bootstrap/weixin/index2.html";i:1491462963;}*/ ?>
<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-lg-10">
        <h2>微信菜单2</h2>
        <ol class="breadcrumb">
            <li>
                <a href="#">首页</a>
            </li>

            <li class="active">
                <strong>微信菜单2</strong>
            </li>
        </ol>
    </div>
</div>

<div class="wrapper wrapper-content animated fadeInRight ecommerce">
    <div class="ibox-content m-b-sm border-bottom" id="form1">

        <div class="row">
            <div class="col-sm-2">
                <select name="type" id="type" class="form-control">
                    <option value="">请选择</option>
                    <?php if(is_array($wxlist)): $i = 0; $__LIST__ = $wxlist;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                    <option value="<?php echo $key; ?>"><?php echo $vo['text']; ?></option>
                    <?php endforeach; endif; else: echo "" ;endif; ?>
                </select>
            </div>
            <div class="col-sm-6">
                <a class="btn btn-success btn-outline" href="javascript:void(0)" id="submitMenu">
                    <i class="fa fa-save"></i>
                    <span class="bold">提交菜单</span>
                </a>
            </div>

        </div>
    </div>
    <div class="row">

        <div class="col-sm-12">
            <div class="ibox-content">
                <textarea name="content" id="content" class="form-control" rows="20"></textarea>
            </div>
        </div>
    </div>
</div>
<script>
    $(document).ready(function () {

        $('#submitMenu').click(function () {
            var v = $('#type').val();
            var menus = $('#content').val().trim();
            if(v && menus){
                YBusy.show('正在提交');
                $.post("<?php echo U('submitMenu2'); ?>", {
                    type:v,
                    menus:menus
                },function (data) {
                    YBusy.hide();
                    try {
                        if (data.status) {
                            YToast.success('提交菜单成功！');
                        } else {
                            YMessager.alert(data.info);
                        }
                    } catch (e) {
                        YMessager.alert(e.message)
                    }
                }, 'json');
            }else{
                YMessager.alert('菜单内容不能为空');
            }

        });


        $('#type').change(function () {
            var v = $(this).val();
            if(v){
                YBusy.show('正在下载菜单');
                $.get("<?php echo U('downMenu'); ?>",{type:v}, function (data) {
                    YBusy.hide();
                    try {
                        $('#content').val(data);
                    } catch (e) {
                        YMessager.alert(e.message)
                    }
                });
            }
        });

    });
</script>